<!--
 * @Author: ChunLai
 * @Date: 2023-08-14 13:47:04
 * @LastEditTime: 2025-09-02 15:07:44
 * @Description: 字段释义
 * @FilePath: \02.bldinsure\src\views\form\components\FieldDescMode.vue
-->
<template>
  <div class="icon_w16" @click.stop="openDesc" v-if="showIcon">
    <MsImgIcon size="16" name="tip" />
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  name: "FieldDescMode",
  props: {
    field: {
      type: String,
      default: () => "",
    },
  },
  data() {
    return {};
  },
  components: {},
  computed: {
    ...mapGetters({
      fieldDescConfig: "page/fieldDescConfig",
    }),
    getFieldLabel() {
      let res = "";
      if (this.field) {
        if (this.field == "validDateEnd") {
          res = "证件有效期止期";
        } else if (this.field == "crsIdType") {
          res = "中国税收居民";
        } else if (this.field == "qsContSelfFlag") {
          res = "自保件";
        }
      }
      return res;
    },
    getFieldDesc() {
      let res = "";
      if (this.field && this.fieldDescConfig[`${this.field}`]) {
        const findObj = this.fieldDescConfig[`${this.field}`].find((ele) =>
          ele.label.includes(this.compEngName)
        );
        if (findObj) {
          if (this.field == "validDateEnd") {
            let strDesc = "";
            if (findObj.descConfig.length > 0) {
              findObj.descConfig.forEach((item) => {
                strDesc += `${item.desc}；<br><br>`;
              });
            }
            res = strDesc;
          } else if (this.field == "crsIdType") {
            if (findObj.descConfig) {
              res = findObj.descConfig;
            }
          } else if (this.field == "qsContSelfFlag") {
            if (findObj.descConfig) {
              res = findObj.descConfig;
            }
          }
        }
      }
      return res;
    },
    showIcon() {
      let res = false;
      if (this.getFieldDesc) {
        res = true;
      }
      return res;
    },
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    openDesc() {
      this.$store.commit("common/SET_FIELD_MEAN_CONT", {
        label: `${this.getFieldLabel}`,
        desc: `${this.getFieldDesc}`,
      });
    },
  },
};
</script>

<style lang="less" scoped>
.icon_w16 {
  display: flex;
  margin-left: 6px;
}
</style>
